<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :list="swiperList"></home-swiper>
    <home-icons :list="iconList"></home-icons>
    <home-recommed :list="recommendList"></home-recommed>
    <home-weekend :list="weekendList"></home-weekend>
  </div>
</template>

<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommed from './components/recommed'
import HomeWeekend from './components/Weekend'
import axios from 'axios'

// 这里定义的是home.vue单文件组件的名字。
export default {
  name: 'home',
  data: function () {
    return {
      swiperList: [],
      city: '',
      iconList: [],
      recommendList: [],
      weekendList: []
    }
  },
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommed,
    HomeWeekend
  },
  methods: {
    getHomeInfo: function () {
      axios.get('/api/index.json').then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc: function (res) {
      console.log(res)
      if (res.data.ret && res.data.data != null) {
        const data = res.data.data
        this.swiperList = data.swiperList
        this.city = data.city
        this.iconList = data.iconList
        this.recommendList = data.recommendList
        this.weekendList = data.weekendList
      }
    }
  },
  mounted: function () {
    this.getHomeInfo()
  }
}
</script>

<style lang="stylus" scoped>

</style>
